﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace Maticsoft.Web
{
    public partial class LoginAdmin : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btn_login_Click(object sender, EventArgs e)
        {
            Maticsoft.BLL.userInfo sm = new BLL.userInfo();

            string pass = this.txt_pass.Text;
            string name = this.txt_name.Text;

            if (string.IsNullOrEmpty(name))
            {
                Maticsoft.Common.MessageBox.Show(this, "请填写登录名！");
                return;
            }
            if (string.IsNullOrEmpty(pass))
            {
                Maticsoft.Common.MessageBox.Show(this, "请填写密码！");
                return;
            }

            DataSet ds = sm.GetList(" login='" + name + "' and pass='" + pass + "' ");

            if (ds.Tables[0].Rows.Count > 0)
            {
                Session["login"] = ds.Tables[0].Rows[0]["user_id"].ToString() + "|admin";
                Response.Redirect("Frame.aspx");
            }
            else
            {
                Maticsoft.Common.MessageBox.Show(this,"用户名密码错误!");
            }
        }
    }
}